<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2017-12-22
 * Time: 下午 10:30
 */
error_reporting(E_ALL ^ E_NOTICE);
require_once 'JKSocket.php';


$client = new JKSocket(8800);

$client->onConnect(function (JKSocket $obj, $args) {
    echo "Connect {$obj->getAddr()} success\n";
});

$client->onClose(function (JKSocket $obj, $args) {
   echo "Connect close\n"; 
});

$client->onRecv(function (JKSocket $obj, $args) {
    $data = $args['data'];
    $obj->send('Ni hao!');
    echo "Server({$obj->getAddr()}): $data\n";
});

if($client->connect()->fail()) {
    echo $client->getLastError();
}